function Pager(page, pageSize, maxIndexSize, total, pagerId, baseUrl){
    this.page = page;
    this.pageSize = pageSize;
    this.maxIndexSize = maxIndexSize;
    this.total = total;
    this.pagerId = pagerId;
    this.baseUrl = baseUrl;
}

Pager.prototype.getPage = function(){
    return this.page;
}

Pager.prototype.getPageSize = function(){
    return this.pageSize;
}

Pager.prototype.getMaxIndexSize = function(){
    return this.maxIndexSize;
}

Pager.prototype.getTotal = function(){
    return this.total;
}

Pager.prototype.isFinalPage = function(){
    return this.getPage()==this.getTotalPage();
}

Pager.prototype.getTotalPage = function(){
    return Math.ceil(this.total/this.pageSize);
}

Pager.prototype.getIndexPages = function(){
    var pages = [];
    var halfIndexPage = Math.floor(this.getTotalPage()/2);
    var left = halfIndexPage;
    var right = halfIndexPage;
    var tmpPage = page;
    // not finished yet.
}


Pager.prototype.createPagerBar = function(selector){
	var leadingChar = '&';
	if(this.baseUrl.indexOf('?')!=-1){
		leadingChar = '&';
	}
	else{
		leadingChar = '?';
	}
    if(this.page!=1){
        var page1Url = this.baseUrl + leadingChar +'page=1&pageSize=' + this.pageSize; 
        $(selector).append('<a href="' + page1Url + '">第一页</a>');
        var priorPageUrl = this.baseUrl + leadingChar + 'page=' + (this.page-1) + '&pageSize=' + this.pageSize;
        $(selector).append('<a href="' + priorPageUrl + '">上一页</a>');

    }
    $(selector).append('<span>共 ' + this.getTotalPage() + ' 页，当前是第 ' + this.page + ' 页</span>');
    if(!this.isFinalPage()){
        var nextPageUrl = this.baseUrl + leadingChar + 'page=' + (this.page+1) + '&pageSize=' + this.pageSize;;
        $(selector).append('<a href="' + nextPageUrl + '">下一页</a>');
        var finalPageUrl = this.baseUrl + leadingChar + 'page=' + this.getTotalPage() + '&pageSize=' + this.pageSize;;
        $(selector).append('<a href="' + finalPageUrl + '">最后一页</a>');
    }
}
